<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script src="https://unpkg.com/axios@0.19.2/dist/axios.min.js"></script>
  <script>
    const url = 'https://www.imooc.com/api/http/search/suggest?words=js';
    const jsonUrl = 'https://www.imooc.com/api/http/json/search/suggest?words=js';
    console.log(axios);
    axios(url,{
      method:'post',
      headers:{
        'Content-Type':'application/x-www-form-urlencoded'
      },
      params:{
        username:'a'
      },
      data:{
        age:18,
        sex:'male'
      },
      // timeout:1,
      // withCredentials:true,
    }).then(response=>{
      console.log(response.data.data);
    }).catch(err=>{
      console.log(err);
    })
    axios.get(url,{params:{name:'a'}}).then(response=>{console.log(response);})
    axios.post(url,'name:a').then(resp=>{console.log(resp);})
    axios.post(jsonUrl,{name:'aa'}).then(resp=>{console.log(resp);})
  </script>
</body>
</html>